#ifndef _BUFFER_H_
#define _BUFFER_H_

#include "common.h"

#define	PROP_NONE				0x00
#define PROP_SYNC_WRITE	0x01

typedef struct Buffer {
	u8 *cache;
	u8 capacity;
	u8 iread;
	u8 iwrite;
	u8 prop;
} Buffer;

void buffer_init(Buffer *buffer, u8 *cache, u8 capacity, u8 prop);

u8 buffer_capacity(Buffer *buffer);
u8 buffer_length(Buffer *buffer);
void buffer_write(Buffer *buffer, u8 value);
u8 buffer_read(Buffer *buffer);
u8 buffer_get(Buffer *buffer, u8 i);
void buffer_skip(Buffer *buffer, u8 n);
void buffer_clear(Buffer *buffer);

u16 buffer_read_u16(Buffer *buffer);
void buffer_write_u16(Buffer *buffer, u16 value);

#endif /* _BUFFER_H_ */